package com.itboye.ihomebank.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.bean.HouseDetailBean.OwnerInfo.OtherHouses;
import com.itboye.ihomebank.constants.NetPublicConstant;
import com.itboye.ihomebank.support.commonadapter.MutiplyCommonAdapter;
import com.itboye.ihomebank.support.commonadapter.ViewHolder;
import com.itboye.ihomebank.util.XImageLoader;

/***
 * 示例adapter
 * 
 * @author mr.w
 * 
 */
public class JinJiRenOtherHouseAdapter extends
		MutiplyCommonAdapter<OtherHouses> {
	int position;

	public JinJiRenOtherHouseAdapter(Context context, List<OtherHouses> datas,
			int... layoutId) {
		super(context, datas, layoutId);
		// TODO Auto-generated constructor stub
	}

	@Override
	public int getItemViewType(int position) {
		// TODO Auto-generated method stub

		return 0;
	}

	@Override
	public void convert(ViewHolder holder, OtherHouses t, int type,
			final int position) {
		// TODO Auto-generated method stub
		XImageLoader.load(NetPublicConstant.IMAGE_URL + t.getMainImg(),
				(ImageView) holder.getView(R.id.houseImage));
		holder.setText(R.id.jianjie, t.getTitle());
		holder.setText(R.id.mianji, t.getHouseArea());
		holder.setText(R.id.dizhi, t.getAddressDetail());
		String[] tagNames=t.getTagNames().split(",");
		holder.removeAllViews(R.id.tagNames);
		if(tagNames!=null){
			if(tagNames.length>0){
				for (int i = 0; i < tagNames.length; i++) {
						View view = LayoutInflater.from(mContext).inflate(
								R.layout.item_other, null);
						TextView textView = (TextView) view.findViewById(R.id.text);
						textView.setTextColor(mContext.getResources().getColor(
								R.color.black));
						textView.setText(tagNames[i]);
						holder.addView(R.id.tagNames, view);
				}
			}
		}
		holder.setText(R.id.house_price, t.getRent()+"元/月");
				
	}

	@Override
	public void getItemPosition(int position) {
		// TODO Auto-generated method stub
		this.position = position;
	}

}
